import 'package:flutter_taotaoshipin/generated/json/base/json_convert_content.dart';
import 'package:flutter_taotaoshipin/model/pay_config_list_entity.dart';

PayConfigListEntity $PayConfigListEntityFromJson(Map<String, dynamic> json) {
  final PayConfigListEntity payConfigListEntity = PayConfigListEntity();
  final List<PayConfigListList>? list = (json['List'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<PayConfigListList>(e) as PayConfigListList)
      .toList();
  if (list != null) {
    payConfigListEntity.list = list;
  }
  final int? paySwitch = jsonConvert.convert<int>(json['pay_switch']);
  if (paySwitch != null) {
    payConfigListEntity.paySwitch = paySwitch;
  }
  final String? paySwitchAppId = jsonConvert.convert<String>(
      json['pay_switch_app_id']);
  if (paySwitchAppId != null) {
    payConfigListEntity.paySwitchAppId = paySwitchAppId;
  }
  final String? paySwitchKfUrl = jsonConvert.convert<String>(
      json['pay_switch_kf_url']);
  if (paySwitchKfUrl != null) {
    payConfigListEntity.paySwitchKfUrl = paySwitchKfUrl;
  }
  final String? paySwitchCorpId = jsonConvert.convert<String>(
      json['pay_switch_corp_id']);
  if (paySwitchCorpId != null) {
    payConfigListEntity.paySwitchCorpId = paySwitchCorpId;
  }
  final int? subDeductTimes = jsonConvert.convert<int>(
      json['sub_deduct_times']);
  if (subDeductTimes != null) {
    payConfigListEntity.subDeductTimes = subDeductTimes;
  }
  final int? userSubTimes = jsonConvert.convert<int>(json['user_sub_times']);
  if (userSubTimes != null) {
    payConfigListEntity.userSubTimes = userSubTimes;
  }
  return payConfigListEntity;
}

Map<String, dynamic> $PayConfigListEntityToJson(PayConfigListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['List'] = entity.list?.map((v) => v.toJson()).toList();
  data['pay_switch'] = entity.paySwitch;
  data['pay_switch_app_id'] = entity.paySwitchAppId;
  data['pay_switch_kf_url'] = entity.paySwitchKfUrl;
  data['pay_switch_corp_id'] = entity.paySwitchCorpId;
  data['sub_deduct_times'] = entity.subDeductTimes;
  data['user_sub_times'] = entity.userSubTimes;
  return data;
}

extension PayConfigListEntityExtension on PayConfigListEntity {
  PayConfigListEntity copyWith({
    List<PayConfigListList>? list,
    int? paySwitch,
    String? paySwitchAppId,
    String? paySwitchKfUrl,
    String? paySwitchCorpId,
    int? subDeductTimes,
    int? userSubTimes,
  }) {
    return PayConfigListEntity()
      ..list = list ?? this.list
      ..paySwitch = paySwitch ?? this.paySwitch
      ..paySwitchAppId = paySwitchAppId ?? this.paySwitchAppId
      ..paySwitchKfUrl = paySwitchKfUrl ?? this.paySwitchKfUrl
      ..paySwitchCorpId = paySwitchCorpId ?? this.paySwitchCorpId
      ..subDeductTimes = subDeductTimes ?? this.subDeductTimes
      ..userSubTimes = userSubTimes ?? this.userSubTimes;
  }
}

PayConfigListList $PayConfigListListFromJson(Map<String, dynamic> json) {
  final PayConfigListList payConfigListList = PayConfigListList();
  final String? cname = jsonConvert.convert<String>(json['cname']);
  if (cname != null) {
    payConfigListList.cname = cname;
  }
  final String? code = jsonConvert.convert<String>(json['code']);
  if (code != null) {
    payConfigListList.code = code;
  }
  final String? account = jsonConvert.convert<String>(json['account']);
  if (account != null) {
    payConfigListList.account = account;
  }
  final int? platform = jsonConvert.convert<int>(json['platform']);
  if (platform != null) {
    payConfigListList.platform = platform;
  }
  return payConfigListList;
}

Map<String, dynamic> $PayConfigListListToJson(PayConfigListList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['cname'] = entity.cname;
  data['code'] = entity.code;
  data['account'] = entity.account;
  data['platform'] = entity.platform;
  return data;
}

extension PayConfigListListExtension on PayConfigListList {
  PayConfigListList copyWith({
    String? cname,
    String? code,
    String? account,
    int? platform,
  }) {
    return PayConfigListList()
      ..cname = cname ?? this.cname
      ..code = code ?? this.code
      ..account = account ?? this.account
      ..platform = platform ?? this.platform;
  }
}